//
//  MLHMainTabbarController.swift
//  molihe
//
//  Created by 姜维克 on 16/6/7.
//  Copyright © 2016年 姜维克. All rights reserved.
//

import UIKit

class MLHMainTabbarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

        setupUI()
    }

    func setupUI(){
//        self.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -3)
        
        addChildController(MLHHomeViewController(), imageName: "tabbar_mlh", title: "魔力盒")
        addChildController(MLHDiscoverViewController(), imageName: "tabbar_fx", title: "发现")

    }
    
    func addChildController(vc:UIViewController, imageName:String, title:String){
        
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imageName)
        
        //设置标签的图片的颜色--渲染方式
        vc.tabBarItem.selectedImage = UIImage(named: imageName + "_focus")?.imageWithRenderingMode(.AlwaysOriginal)
        //.imageWithRenderingMode(.AlwaysOriginal) 按照图片的真实颜色来渲染图片
        
        
        
        //统一设置tabbar里标签内容的颜色,包括图片和文字
        //        tabBar.tintColor = UIColor.orangeColor()
        
        //设置标签的文字颜色 NSForegroundColorAttributeName前景文字颜色 Selected选中状态
//        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor()], forState: .Selected)
        //设置标签文字的偏移y方向
        vc.tabBarItem.titlePositionAdjustment = UIOffsetMake(0, -3)

        
        addChildViewController(vc)

    }


}
